﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace YmtUserAuth.DataImport
{
    public class ReadFile
    {
        public static IEnumerable<string[]> SyncRead(string filePath)
        {
            using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
            using (var rs = new StreamReader(fs, Encoding.GetEncoding("gb2312")))
            {
                var rLine = "";
                while (!string.IsNullOrEmpty(rLine = rs.ReadLine()))
                {
                    if (rLine.Split(new char[] { ',' }).Length == 1)
                    {
                        continue;
                    }
                    yield return rLine.Split(new char[] { ',' });
                }
            }
        }


        //public static IEnumerable<string[]> AsyncRead(string filePath)
        //{
        //    using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
        //    using (var rs = new StreamReader(fs, Encoding.GetEncoding("gb2312")))
        //    {
        //        // rs.ToObservableLines(
        //    }

        //}
    }
}
